﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aphalina.Compression;

namespace Zip.Demo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var stream = File.Create("c://1.zip");
            var zipPackage = ZipPackage.Create(stream);
            zipPackage.WriteFile("abc.txt").WriteByte(80);
            zipPackage.WriteFile("王玉宝/abc1.txt").WriteByte(85);
            zipPackage.Close();
            stream.Close();
        }

        private void ButtonOpenClick(object sender, RoutedEventArgs e)
        {
            var stream = File.OpenRead("c://新压缩格式.zip");
            var zipPackage = ZipPackage.Open(stream);
            this.listBox.ItemsSource = zipPackage.FileNames;
            zipPackage.ReadFile("document.xml");
            stream.Close();
        }
    }
}
